//
//  MainViewController.m
//  MyShiDiQuan
//
//  Created by cvicseks-mac1 on 16/9/6.
//  Copyright © 2016年 cvicseks-mac1. All rights reserved.
//

#import "MainViewController.h"
#import "needfile.h"
// navigationItemTitle
#import "TitleView.h"
// bar
#import "MainViewBar.h"
// 自动布局
#import "Masonry.h"


@interface MainViewController ()

@property (nonatomic, strong) MainViewBar *mainViewBar;

@end

@implementation MainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNavigationBar];
//    [self.view addSubview:self.mainViewBar];// 这样懒加载才起作用
    [self setmainViewBar];
    // Do any additional setup after loading the view.
}

- (void)setNavigationBar{
    self.navigationController.navigationBar.barTintColor = SYSCOLOR;
    TitleView *titleView = [[TitleView alloc] initWithFrame:CGRectMake(0, 0, 210, 30)];
    [titleView setTitleStyleWithTitle:@"输入商家/类型/关键词"];
    self.navigationItem.titleView = titleView;
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
}

- (MainViewBar *)mainViewBar{
    if (!_mainViewBar) {
        _mainViewBar = [[MainViewBar alloc] init];
        _mainViewBar.backgroundColor = [UIColor whiteColor];
//        _mainViewBar.frame = CGRectMake(0, kMaxY, kWIDTH, 80);
        [self.view addSubview:_mainViewBar];
        [_mainViewBar mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.view);
            make.top.equalTo(self.view).with.offset(kMaxY);
            make.right.equalTo(self.view);
            make.height.equalTo(@80);
        }];
    }
    return _mainViewBar;
}

- (void)setmainViewBar{
    [self.mainViewBar setBtnsWithTitle:@[@"个体",@"公司",@"拉货",@"载客",@"农户"] andImage:@[@"tab4",@"tab4",@"tab4",@"tab4",@"tab4"]];
    [self.mainViewBar addBtnClickedActionBlock:^(btnTag tag) {
        NSLog(@"%ld",(long)tag);
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
